package com.bw.shop2208a

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.core.view.isVisible
import com.bw.shop2208a.databinding.ActivityWebViewBinding
import com.bw.shop2208a.mvvm.BaseViewActivity

class WebViewActivity : BaseViewActivity<ActivityWebViewBinding>() {
    override fun initViwe() {
        val url: String = intent.getStringExtra("web_url").toString()
        binding.web.loadUrl(url)
        binding.web.webViewClient = WebViewClient()
        binding.web.settings.javaScriptEnabled = true//网页上的事件可以点击
        binding.web.webChromeClient = object : WebChromeClient() {
            override fun onProgressChanged(view: WebView?, newProgress: Int) {
                super.onProgressChanged(view, newProgress)
                if (newProgress == 100) {
                    binding.progress.isVisible = false
                } else {
                    binding.progress.progress = newProgress
                }
            }
        }
    }

    override fun iniData() {

    }

    override fun getLayoutId(): Int = R.layout.activity_web_view
}